/*
 * Gps.java
 *
 * Created on 3 de Maio de 2007, 19:14
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.onmotion.gps;

import net.onmotion.Location;

/**
 *
 * @author sestevao
 */
public abstract class Gps {
    
    public final static int LOCATION_NONE = 0;
    public final static int LOCATION_BT = 1;
    public final static int LOCATION_INTERNAL = 2;
    public final static int LOCATION_FAKE = 3;
    
    public abstract Location getLocation();
    public abstract boolean isConnected();
    public abstract void start();
    public abstract void stop();
    
    public static Gps getGps(int aLocationMethod) {
        Gps gpsReader = null;
        switch (aLocationMethod) {
            case(LOCATION_BT):
            {
                gpsReader = GpsBt.instance();                
            }
            break;
            case(LOCATION_INTERNAL):
            {
                try {
                    Class.forName("javax.microedition.location.LocationProvider");
                    gpsReader = (Gps)(Class.forName("net.onmotion.gps.GpsInternal").newInstance());                    
                } catch (Throwable ex) {
                    gpsReader = null;                    
                }
            }
            break;
            case(LOCATION_FAKE): {
                gpsReader = GpsFake.getInstance();
            }
            break;
            case (LOCATION_NONE): {
                gpsReader = null;
            }
        }
        
        return gpsReader;
    }
    
}
